#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char *argv[])
{
	int fd;
	
	char buf[32];
	
	fd = open(argv[1], O_RDWR, 0666);
	if(fd<0)
	{
		printf("open is error\r\n");
		return -1;
	}
	printf("open is ok\r\n");
	
	if(!strcmp(argv[2], "read"))
	{
		read(fd, buf, 32);
	}
	else if(!strcmp(argv[2], "write"))
	{
		write(fd, "hello\r\n", 7);
	}
	
	close(fd);
	
	return 0;
}